<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateArticleTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('article', function (Blueprint $table) {
            $table->increments('id');
            $table->integer('category')->default(0)->comment('類別 0->默认类别');
            $table->string('title')->default('')->comment('标题');
            $table->string('keyword')->default('')->comment('关键词');
            $table->string('description')->default('')->comment('描述');
            $table->text('images')->nullable()->comment('封面圖片');
            $table->string('color')->default('')->comment('标题顏色');
            $table->text('content')->nullable()->comment('內容');
            $table->string('author')->default(0)->comment('發佈人');
            $table->boolean('state')->default(1)->comment('0=隱藏 1=顯示');
            $table->integer('views')->default(0)->comment('閲讀次數');
            $table->datetime('start_at')->nullable()->comment('開始效期');
            $table->datetime('deadline_at')->nullable()->comment('截止效期');
            $table->timestamps();

            $table->index('category');
            $table->index(['start_at', 'deadline_at'], 'sata');
            $table->index('created_at');
            $table->index('updated_at');
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('article');
    }
}
